package jp.co.irep.tech.juten.bean.utils;

import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

public class BeanUtil {

    /**
     * エラーを表示する
     * @param type
     * @param err
     */
    public static void setMessage(String type, String err) {
        FacesMessage message = null;
        if (type.equals("error"))
            message = new FacesMessage(FacesMessage.SEVERITY_ERROR, err, "");
        if (type.equals("info"))
            message = new FacesMessage(FacesMessage.SEVERITY_INFO, err, "");
        FacesContext.getCurrentInstance().getExternalContext().getFlash()
                .setKeepMessages(true);
        FacesContext.getCurrentInstance().addMessage(null, message);

    }

    /**
     * WEBINFパス取得
     * 
     * @return
     */
    public static String getWebInfPath() {
        ExternalContext extContext = FacesContext.getCurrentInstance()
                .getExternalContext();
        return extContext.getRealPath("//WEB-INF");
    }

}
